﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpObjects.SearchEngine.HtmlParsing.Html
{
    public class HtmlHeadingTag : HtmlContainerTag
    {
        private string name;

        public const string TagName1 = "h1";
        public const string TagName2 = "h2";
        public const string TagName3 = "h3";
        public const string TagName4 = "h4";
        public const string TagName5 = "h5";
        public const string TagName6 = "h6";

        public override string Name { get { return this.name; } set { this.name = value; } }

        public HtmlHeadingTag(HtmlGenericTag tag = null)
            : base(tag)
        {
            if (tag != null)
            {
                this.name = tag.Name;
            }
            else
            {
                this.name = string.Empty;
            }
        }

        public override double IndexingBoost
        {
            get
            {
                string name = this.Name.ToLower();

                switch (name)
                {
                    case "h1":
                        return 4.0;
                    case "h2":
                        return 3.5;
                    case "h3":
                        return 3.0;
                    case "h4":
                        return 2.5;
                    case "h5":
                        return 2.0;
                    case "h6":
                        return 1.5;
                    default:
                        return 1.0;
                }
            }
            set {}
        }


        public static HtmlTag CreateInstance(HtmlGenericTag tag)
        {
            return new HtmlHeadingTag(tag);
        }

        public override bool IsContent { get { return true; } set { } }

    }
}
